#include <bits/stdc++.h>
using namespace std;
void solve(){
    int n,m,l,v,ans1=0;
    set<int>ans2;
    cin>>n>>m>>l>>v;
    vector<vector<int>>b;
    b.resize(n);
    for(int i=0;i<n;i++){
        int x,y,z;
        cin>>x>>y>>z;
        b[i].push_back(x);
        b[i].push_back(y);
        b[i].push_back(z);
    }
    int p[m];
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<n;i++){
        double path=0;
        if(b[i][2]!=0) path=pow(v,2)*b[i][1]/2/b[i][2];
        if(b[i][2]>0){
            if(b[i][1]>=v and b[i][0]==0){
                ans1++;

            }
            else if(b[i][1]>=v and b[i][0]!=0){
                ans1++;
                ans2.insert(*upper_bound(p,p+m,path+b[i][0]));
            }
            else if(sqrt(pow(b[i][1],2)+2*b[i][2]*(l-b[i][0]))>=v){
                ans1++;
            }
            else if(path+b[i][0]<=l){
                ans1++;
                ans2.insert(*upper_bound(p,p+m,path+b[i][0]));
            }
        }
        if(b[i][2]==0){
            if(b[i][1]>=v and b[i][0]==0){
                ans2.insert(0);
                ans1++;
            }
            if(b[i][1]>=v and b[i][0]!=0){
                ans2.insert(*upper_bound(p,p+m,b[i][0]));
                ans1++;
            }
        }
        if(b[i][2]<0){
            if(b[i][1]>=v){
                if(b[i][0]==0){
                    ans2.insert(0);
                    ans1++;
                }
                else{
                    if(*upper_bound(p,p+m,path+b[i][0])<path+b[i][0]){
                        ans1++;
                        ans2.insert(*upper_bound(p,p+m,path+b[i][0]));
                    }
                }
            }
        }
    }
    for(auto c:ans2)cout<<c<<' ';
    cout<<endl;
    cout<<ans1<<' '<<m-ans2.size();
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}
